<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <%@ include file="/sysoutUtil/inc.jsp" %>
    <title>个人省份证</title>
</head>
<body>
    <table class="table" id="AuthUserIdcard-table" border="1"></table>
    <script>
        $.ajax({
        url:'http://localhost:8071/AuthUserIdcard/SelectAuthUserIdcard',
        type:'get',
        dataType:'json',
        success:function(data){
            var str = "";
            var examStatus = 2;
            var examStatus2 = 3;
            str='<tr>\n' +
                '<td>主键</td>\n' +
                '<td>真实姓名</td>\n' +
                '<td>证件号</td>\n' +
                '<td>认证状态</td>\n' +
                '<td>证件到期时间</td>\n' +
                '<td>用户名称</td>\n' +
                '<td>操作9999</td>\n' +
                '</td>\n' +
                '</tr>';
            for ( var i = 0; i < data.length; i++) {
                var examStatus3="";
                var examStatus1 = data[i].examStatus;
                if(examStatus1==1){
                    examStatus3="请求认证"
                }else{
                    examStatus3="认证失败"
                }
            str +=
                '<tr>\n' +
                    '<td>'+data[i].verifyId+'</td>\n' +
                    '<td>'+data[i].realName+'</td>\n' +
                    '<td>'+data[i].verifyNumber+'</td>\n' +
                    '<td>'+examStatus3+'</td>\n' +
                    '<td>'+data[i].verifyTime+'</td>\n' +
                    '<td>'+data[i].userName+'</td>\n' +
                    "<td><input type='button' value='认证通过' onclick=' updateYes2(\""+data[i].verifyId+"\","+examStatus+","+data[i].userId+")'><input type='button' value='认证驳回' onclick='updateNo2(\""+data[i].verifyId+"\","+examStatus2+","+data[i].userId+")'> </td>\n"+
                    '</td>\n'+
                    '</tr>'
            }
            $("#AuthUserIdcard-table").html(str)

            }
            });
        //认证通过
        function updateYes2(verifyId,examStatus,userid){
            alert(verifyId+"---"+examStatus+"-----"+userid);
            $.ajax({
                url:'http://localhost:8071/AuthUserIdcard/UpdateAuthUserIdcard',
                data:{
                    "verifyId":verifyId,
                    "examStatus":examStatus,
                    "userid":userid
                },
                type:'put',
                dataType:'json',
                success:function(data){
                    if(data==1){
                        alert("成功")
                    }else{
                        alert("失败")
                    }

                }
            })
        }
        //认证失败
        function updateNo2(verifyId,examStatus2,userid){
            alert(verifyId+"---"+examStatus2+"-----"+userid)
            $.ajax({
                url:'http://localhost:8071/AuthUserIdcard/UpdateAuthUserIdcard',
                data:{
                    "verifyId":verifyId,
                    "examStatus":examStatus2,
                    "userid":userid
                },
                type:'put',
                dataType:'json',
                success:function(data){
                    if(data==1){
                        alert("成功")
                    }else{
                        alert("失败")
                    }

                }
            })
        }
    </script>
</body>
</html>
